# -*- codeing = utf-8 -*-
# @Time : 2024/8/13 13:30
# @Author:北希
# @File :getBottomLeft.py
# @Software: PyCharm
import re
from .getPublicData import *

def getSquareData():
    cars = list(getAllCars())
    carVolume = {}
    for i in cars:
        if carVolume.get(i.carName,-1)== -1:
            carVolume[str(i.carName)] = int(i.saleVolume)
        else:
            carVolume[str(i.carName)] += int(i.saleVolume)

    carSortVolume =  sorted(carVolume.items(),key=lambda x:x[1],reverse=True)[:15]
    brandList = []
    volumeList = []
    priceList = []
    for i in carSortVolume:
        brandList.append(i[0])
        volumeList.append(i[1])
    for j in cars[:15]:
        j.price = re.findall('\d+\.\d+',j.price)
        j.price = j.price[0]
        priceList.append(j.price)
    return brandList,volumeList,priceList
